<?php
namespace Amis\functions;

use Amis\Basics\AmisBasics;

class Actions extends AmisBasics
{
    public string $type = 'action';

    public function actionType(string $actionType)
    {
        if (in_array($actionType, ['ajax', 'link', 'url', 'drawer', 'dialog', 'confirm', 'cancel', 'prev', 'next', 'copy', 'close'])) {
            $this->actionType = $actionType;
        }
        return $this;
    }

    public function label($label)
    {
        $this->label = $label;
        return $this;
    }

    public function level(string $level = 'default')
    {
        if (in_array($level, ['link', 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark', 'default'])) {
            $this->level = $level;
        }
        return $this;
    }

    public function size(string $size = '')
    {
        if (in_array($size, ['xs', 'sm', 'md', 'lg'])) {
            $this->size = $size;
        }
        return $this;
    }

    public function icon($icon)
    {
        $this->icon = $icon;
        return $this;
    }

    public function iconClassName($iconClassName)
    {
        $this->iconClassName = $iconClassName;
        return $this;
    }

    public function rightIcon($rightIcon)
    {
        $this->rightIcon = $rightIcon;
        return $this;
    }

    public function className($className)
    {
        $this->className = $className;
        return $this;
    }

    public function rightIconClassName($rightIconClassName)
    {
        $this->rightIconClassName = $rightIconClassName;
        return $this;
    }

    public function active(bool $active = false)
    {
        $this->active = $active;
        return $this;
    }

    public function activeLevel(string $level)
    {
        $this->activeLevel = $level;
        return $this;
    }

    public function activeClassName(string $activeClassName = 'is-active')
    {
        $this->activeClassName = $activeClassName;
        return $this;
    }

    public function block(bool $block = false)
    {
        $this->block = $block;
        return $this;
    }

    public function confirmText($confirmText)
    {
        $this->confirmText = $confirmText;
        return $this;
    }

    /**
     * 指定此次操作完后，需要刷新的目标组件名字（组件的name值，自己配置的），多个请用 , 号隔开。
     * @param $reload
     * @return $this
     */
    public function reload($reload)
    {
        $this->reload = $reload;
        return $this;
    }

    public function tooltip($tooltip)
    {
        $this->tooltip = $tooltip;
        return $this;
    }

    public function disabledTip($disabledTip)
    {
        $this->disabledTip = $disabledTip;
        return $this;
    }

    public function tooltipPlacement($tooltipPlacement)
    {
        $this->tooltipPlacement = $tooltipPlacement;
        return $this;
    }

    public function close($close = 'dashed')
    {
        $this->close = $close == 'boolean' ?: 'string';
        return $this;
    }

    public function required($required = '')
    {
        $this->required = $required;
        return $this;
    }
}